<!DOCTYPE html>
<html>
<head>
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?d890b1f16fb364253e79c5bb20225c3a";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>


    

    

    
<!-- Baidu Tongji -->
<script>var _hmt = _hmt || []</script>
<script async src="//hm.baidu.com/hm.js?busuanzi_value_site_uv"></script>
<!-- End Baidu Tongji -->




    <meta charset="utf-8">
    <meta name="baidu-site-verification" content="FYMCShbUK8" />
    <meta name="baidu-site-verification" content="ZYRF7OxQRW" />
    <meta name="baidu-site-verification" content="cHSqtjI0PN" />
    <meta name="baidu-site-verification" content="cHSqtjI0PN" />
    <meta name="baidu-site-verification" content="cHSqtjI0PN" />
    
    
    <link rel="canonical" href="https://hhardyy.com/2018/05/19/vue组件通信/">
    
    
    <title>vue组件通信 | 小方块 - hhardyy.com | 复杂的坑+归其原理+了解实现规则===解决？解决成功：加油解决成功;</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#958e93">
    
    
    <meta name="keywords" content="vue,props,$emit,$on,父子组件通信,非父子组件通信">
    <meta name="description" content="这里我没用脚手架，可以用html和js的思维了解，最重要的是这次的音乐是我最喜欢的Flower Dance">
<meta name="keywords" content="vue,props,$emit,$on,父子组件通信,非父子组件通信">
<meta property="og:type" content="article">
<meta property="og:title" content="vue组件通信">
<meta property="og:url" content="http://yoursite.com/2018/05/19/vue组件通信/index.html">
<meta property="og:site_name" content="小方块 - hhardyy.com">
<meta property="og:description" content="这里我没用脚手架，可以用html和js的思维了解，最重要的是这次的音乐是我最喜欢的Flower Dance">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://yoursite.com/images/props_img/props.JPG">
<meta property="og:image" content="http://yoursite.com/images/props_img/1.png">
<meta property="og:image" content="http://yoursite.com/images/props_img/2.JPG">
<meta property="og:image" content="http://yoursite.com/images/props_img/3.JPG">
<meta property="og:updated_time" content="2020-01-13T15:27:46.608Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="vue组件通信">
<meta name="twitter:description" content="这里我没用脚手架，可以用html和js的思维了解，最重要的是这次的音乐是我最喜欢的Flower Dance">
<meta name="twitter:image" content="http://yoursite.com/images/props_img/props.JPG">
    
        <link rel="alternate" type="application/atom+xml" title="小方块 - hhardyy.com" href="/atom.xml">
    
    <link rel="shortcut icon" href="/hardyfavicon.ico">
    <link rel="stylesheet" href="//unpkg.com/hexo-theme-material-indigo@latest/css/style.css">
    <script>window.lazyScripts=[]</script>

    <!-- custom head -->
    

</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide" >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(/img/paulGraham.jpg)">
      <div class="brand" style="background-color:#4154b2">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="/img/avatar.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">BingZhenhuang</h5>
          <a href="mailto:huangbingzhen@hhardyy.com" title="huangbingzhen@hhardyy.com" class="mail">huangbingzhen@hhardyy.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/"  >
                <i class="icon icon-lg icon-home"></i>
                主页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/archives"  >
                <i class="icon icon-lg icon-archives"></i>
                所有文章
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags"  >
                <i class="icon icon-lg icon-tags"></i>
                标签
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/HHardyy" target="_blank" >
                <i class="icon icon-lg icon-github"></i>
                Github
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://gitee.com/hhardyy" target="_blank" >
                <i class="icon icon-lg icon-cloud"></i>
                Gitee
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://juejin.im/user/59a26f926fb9a02487553b04"  >
                <i class="icon icon-lg icon-pencil"></i>
                掘金-圳
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://segmentfault.com/u/hhardyy"  >
                <i class="icon icon-lg icon-comments"></i>
                Segmentfault
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://codepen.io/HHardyy/" target="_blank" >
                <i class="icon icon-lg icon-codepen"></i>
                Codepen
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://www.freecodecamp.cn/hhardyy" target="_blank" >
                <i class="icon icon-lg icon-leaf"></i>
                Freecodecamp
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/友情链接"  >
                <i class="icon icon-lg icon-link"></i>
                友链
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">vue组件通信</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">vue组件通信</h1>
        <h5 class="subtitle">
            
                <time datetime="2018-05-18T16:56:35.000Z" itemprop="datePublished" class="page-time">
  2018-05-19
</time>


            
        </h5>
    </div>

    


</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#父组件把数据传给子组件用props"><span class="post-toc-number">1.</span> <span class="post-toc-text">父组件把数据传给子组件用props</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#子组件可以使用-emit-触发父组件的自定义事件-也可以用on事件监听"><span class="post-toc-number">2.</span> <span class="post-toc-text">子组件可以使用 $emit 触发父组件的自定义事件,也可以用on事件监听</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#非父子组件通信"><span class="post-toc-number">3.</span> <span class="post-toc-text">非父子组件通信</span></a></li></ol>
        </nav>
    </aside>
    
<article id="post-vue组件通信"
  class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">vue组件通信</h1>
        <div class="post-meta">
            <time class="post-time" title="2018-05-19 00:56:35" datetime="2018-05-18T16:56:35.000Z"  itemprop="datePublished">2018-05-19</time>

            


            

        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <p>这里我没用脚手架，可以用html和js的思维了解，最重要的是这次的音乐是我最喜欢的Flower Dance</p>
<p><iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width="330" height="86" src="//music.163.com/outchain/player?type=2&id=420401412&auto=0&height=66"></iframe><br><a id="more"></a><br>据说父子组件通信很难理解，瑟瑟发抖的写一下<br>先说它们的通信方式不是移动联通电信~</p>
<h3 id="父组件把数据传给子组件用props"><a href="#父组件把数据传给子组件用props" class="headerlink" title="父组件把数据传给子组件用props"></a>父组件把数据传给子组件用props</h3><figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="/images/props_img/props.JPG" alt="“props的一些属性”" title="">
                </div>
                <div class="image-caption">“props的一些属性”</div>
            </figure> 
<p>用法：<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="comment">//subassembly是一个注册了的子组件</span></div><div class="line"> &lt;subassembly v-<span class="keyword">for</span>=<span class="string">"(item,index) in list"</span> :content=<span class="string">"item"</span>&gt;<span class="xml"><span class="tag">&lt;/<span class="name">subassembly</span>&gt;</span></span></div><div class="line"> Vue.component(<span class="string">'subassembly'</span>, &#123;</div><div class="line">        props: [<span class="string">'content'</span>],</div><div class="line">        template: <span class="string">'&lt;li&gt;&#123;&#123;content&#125;&#125;&lt;/li&gt;'</span></div><div class="line">&#125;);</div><div class="line">item是父组件v-<span class="keyword">for</span>循环出来的东西</div></pre></td></tr></table></figure></p>
<figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="/images/props_img/1.png" alt="“拿到父组件循环的item数据显示”" title="">
                </div>
                <div class="image-caption">“拿到父组件循环的item数据显示”</div>
            </figure>  
<p>这个会做成单独的组件是为了应付数据多的时候单独做成一个组件比较好</p>
<h3 id="子组件可以使用-emit-触发父组件的自定义事件-也可以用on事件监听"><a href="#子组件可以使用-emit-触发父组件的自定义事件-也可以用on事件监听" class="headerlink" title="子组件可以使用 $emit 触发父组件的自定义事件,也可以用on事件监听"></a>子组件可以使用 $emit 触发父组件的自定义事件,也可以用on事件监听</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">vm.$emit( event, arg ) <span class="comment">//触发当前实例上的事件处理函数</span></div><div class="line">vm.$on( event, func ) <span class="comment">//监听event事件后执行事件处理函数</span></div></pre></td></tr></table></figure>
<p>这里用$emit举例假如要删掉生成的数据，这时候需要在子组件写这样的方法<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">Vue.component(<span class="string">'subassembly'</span>, &#123;</div><div class="line">        props: [<span class="string">'content'</span>, <span class="string">'index'</span>],</div><div class="line">        template: <span class="string">'&lt;li @click="handleFunction"&gt;&#123;&#123;content&#125;&#125;&lt;/li&gt;'</span>,</div><div class="line">        methods: &#123;</div><div class="line">            handleFunction: <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</div><div class="line">                <span class="keyword">this</span>.$emit(<span class="string">'delete'</span>, <span class="keyword">this</span>.index)</div><div class="line">            &#125;</div><div class="line">        &#125;</div><div class="line">&#125;);</div></pre></td></tr></table></figure></p>
<p>这样子组件被点击的时候就会触发delete,此时父组件v-on了一个delete触发父组件的delfunction方法，并且传过去一个index<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line">&lt;subassembly</div><div class="line">        v-<span class="keyword">for</span>=<span class="string">"(item,index) in list"</span> :key=<span class="string">"index"</span> :content=<span class="string">"item"</span></div><div class="line">        :index=<span class="string">"index"</span></div><div class="line">        @<span class="keyword">delete</span>=<span class="string">"delfunction"</span>&gt;</div><div class="line">&lt;<span class="regexp">/subassembly&gt;</span></div><div class="line"><span class="regexp"></span></div><div class="line"><span class="regexp">Vue.component('subassembly', &#123;</span></div><div class="line"><span class="regexp">        props: ['content', 'index'],</span></div><div class="line"><span class="regexp">        template: '&lt;li @click="handleFunction"&gt;&#123;&#123;content&#125;&#125;&lt;/</span>li&gt;<span class="string">',</span></div><div class="line"><span class="string">        methods: &#123;</span></div><div class="line"><span class="string">            handleFunction: function () &#123;</span></div><div class="line"><span class="string">                this.$emit('</span><span class="keyword">delete</span><span class="string">', this.index)</span></div><div class="line"><span class="string">            &#125;</span></div><div class="line"><span class="string">        &#125;</span></div><div class="line"><span class="string">    &#125;);</span></div></pre></td></tr></table></figure></p>
<p>delfunction：<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">delfunction: <span class="function"><span class="keyword">function</span> (<span class="params">index</span>) </span>&#123;</div><div class="line">        alert(<span class="string">"删掉了"</span>);</div><div class="line">        <span class="keyword">this</span>.list.splice(index, <span class="number">1</span>);</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>父组件接收到子组件传过来的index之后就删掉相应数据，vue是数据驱动的，这么干就实现了删除功能<br>有点绕。</p>
<h3 id="非父子组件通信"><a href="#非父子组件通信" class="headerlink" title="非父子组件通信"></a>非父子组件通信</h3><p>非父子组件通信可以用vuex和下面举例的这个方法，当然一般用vuex比较好。<br>官网的api指出可以使用空vue实例作为事件中央线！也就是说非父子组件之间的通信，必须要有公共的实例（可以是空的），才能使用 $emit 获取 $on 的数据参数，实现组件通信。<br>比如现在创建了cail组件，希望让他们的值可以互传<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">&lt;cail content=<span class="string">"brother1"</span>&gt;<span class="xml"><span class="tag">&lt;/<span class="name">cail</span>&gt;</span></span></div><div class="line">&lt;cail content=<span class="string">"brother2"</span>&gt;<span class="xml"><span class="tag">&lt;/<span class="name">cail</span>&gt;</span></span></div></pre></td></tr></table></figure></p>
<figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="/images/props_img/2.JPG" alt="“效果图”" title="">
                </div>
                <div class="image-caption">“效果图”</div>
            </figure>  
<p>先定义一个公共的中央线<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">Vue.prototype.bus = <span class="keyword">new</span> Vue();</div></pre></td></tr></table></figure></p>
<p>给组件绑定上一个sonclick事件，然后通过$emit传参<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">sonhandl: <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</div><div class="line">    <span class="keyword">this</span>.bus.$emit(<span class="string">'sonclick'</span>, <span class="keyword">this</span>.soncontent);</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>因为vue是单向数据流关系，不允许子修改父组件的数据，虽然不会报错，但是会报警告，所以在声明子组件的时候只能定义一个soncontent来装父级传过来的content。<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">data: <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</div><div class="line">    <span class="keyword">return</span> &#123;</div><div class="line">        soncontent: <span class="keyword">this</span>.content</div><div class="line">    &#125;</div></pre></td></tr></table></figure></p>
<p>接着用钩子函数通过$on监听sonclick事件<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">mounted: <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</div><div class="line">    <span class="keyword">var</span> this_ = <span class="keyword">this</span>;</div><div class="line">    <span class="keyword">this</span>.bus.$on(<span class="string">'sonclick'</span>, <span class="function"><span class="keyword">function</span> (<span class="params">msg</span>) </span>&#123;</div><div class="line">        this_.soncontent = msg;</div><div class="line">        &#125;)</div><div class="line">    &#125;</div></pre></td></tr></table></figure></p>
<p>这样就实现了点击brother1的时候，组件值也传到brother2<br><figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="/images/props_img/3.JPG" alt="“效果”" title="">
                </div>
                <div class="image-caption">“效果”</div>
            </figure>  </p>
<p>理解简单点就是兄组件绑定一个handelFunction<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">&lt;div @click=<span class="string">"handelFunction"</span>&gt;<span class="xml"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span></div><div class="line">methods: &#123;</div><div class="line">    handelFunction() &#123;</div><div class="line">        vm.$emit(<span class="string">'hanFunction'</span>,<span class="string">'HHardyy'</span>); <span class="comment">//触发事件</span></div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>弟组件on监听hanFunction<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">created() &#123;</div><div class="line">  vm.$on(<span class="string">'hanFunction'</span>, (re) =&gt; &#123; </div><div class="line">        <span class="keyword">this</span>.test= re; <span class="comment">// 接收HHardyy</span></div><div class="line">    &#125;);</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>可以理解成<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> bus = <span class="keyword">new</span> Vue()<span class="comment">//这个可以新建一个event.js,里头let bus=new Vue(); 然后把把bus向外export</span></div><div class="line"></div><div class="line"><span class="comment">// 触发组件 A 中的事件</span></div><div class="line">bus.$emit(<span class="string">'id-selected'</span>, <span class="number">1</span>)</div><div class="line"><span class="comment">// 在组件 B 创建的钩子中监听事件</span></div><div class="line">bus.$on(<span class="string">'id-selected'</span>, <span class="function"><span class="keyword">function</span> (<span class="params">id</span>) </span>&#123;</div><div class="line">  <span class="comment">// ...</span></div><div class="line">&#125;)</div></pre></td></tr></table></figure></p>

        </div>

        <blockquote class="post-copyright">
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2020-01-13T15:27:46.608Z" itemprop="dateUpdated">2020-01-13 23:27:46</time>
</span><br>


        
        谢谢浏览，我会继续努力的，示例：<a href="/2018/05/19/vue组件通信/" target="_blank" rel="external">http://yoursite.com/2018/05/19/vue组件通信/</a>
        
    </div>
    <footer>
        <a href="http://yoursite.com">
            <img src="/img/avatar.jpg" alt="BingZhenhuang">
            BingZhenhuang
        </a>
    </footer>
</blockquote>

        
<div class="page-reward">
    <a id="rewardBtn" href="javascript:;" class="page-reward-btn waves-effect waves-circle waves-light">赏</a>
</div>



        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/emit/">$emit</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/on/">$on</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/props/">props</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/vue/">vue</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/父子组件通信/">父子组件通信</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/非父子组件通信/">非父子组件通信</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://yoursite.com/2018/05/19/vue组件通信/&title=《vue组件通信》 — 小方块 - hhardyy.com&pic=http://yoursite.com/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://yoursite.com/2018/05/19/vue组件通信/&title=《vue组件通信》 — 小方块 - hhardyy.com&source=这里我没用脚手架，可以用html和js的思维了解，最重要的是这次的音乐是我最喜欢的Flower Dance
" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://yoursite.com/2018/05/19/vue组件通信/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《vue组件通信》 — 小方块 - hhardyy.com&url=http://yoursite.com/2018/05/19/vue组件通信/&via=http://yoursite.com" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://yoursite.com/2018/05/19/vue组件通信/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/2018/06/10/Vue全家桶开发旅游app/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">Vue全家桶开发旅游app</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/2018/05/13/ES6的基本玩法/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">ES6的基本玩法</h4>
      </a>
    </div>
  
</nav>



    














</article>

<div id="reward" class="page-modal reward-lay">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <h3 class="reward-title">
        <i class="icon icon-quote-left"></i>
        🤠 请我喝可乐！
        <i class="icon icon-quote-right"></i>
    </h3>
    <div class="reward-content" style="width:50%">
        
        <div class="reward-code" style="text-align:center">
            <div style="width:300px;margin:0px auto;">
               <img id="rewardCode" style="width:50%;height:60%;display:block; margin:0px auto;" src="/img/alipay.jpg" alt="支付宝打赏二维码">
               <span style="display:inline-block; margin-bottom:20px;">0.88(支付宝 aliPay)</span>
               <img id="rewardCode" style="width:50%;height:60%;display:block; margin:0px auto;" src="/img/wechat.jpg" alt="微信打赏二维码">
               <span style="display:inline-block;">0.88(微信 weChat)</span>
            </div>
        </div>
    </div>
</div>



</div>

        <script>
!function(e,t,a){function n(){c(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"),o(),r()}function r(){for(var e=0;e<d.length;e++)d[e].alpha<=0?(t.body.removeChild(d[e].el),d.splice(e,1)):(d[e].y--,d[e].scale+=.004,d[e].alpha-=.013,d[e].el.style.cssText="left:"+d[e].x+"px;top:"+d[e].y+"px;opacity:"+d[e].alpha+";transform:scale("+d[e].scale+","+d[e].scale+") rotate(45deg);background:"+d[e].color+";z-index:99999");requestAnimationFrame(r)}function o(){var t="function"==typeof e.onclick&&e.onclick;e.onclick=function(e){t&&t(),i(e)}}function i(e){var a=t.createElement("div");a.className="heart",d.push({el:a,x:e.clientX-5,y:e.clientY-5,scale:1,alpha:1,color:s()}),t.body.appendChild(a)}function c(e){var a=t.createElement("style");a.type="text/css";try{a.appendChild(t.createTextNode(e))}catch(t){a.styleSheet.cssText=e}t.getElementsByTagName("head")[0].appendChild(a)}function s(){return"rgb("+~~(255*Math.random())+","+~~(255*Math.random())+","+~~(255*Math.random())+")"}var d=[];e.requestAnimationFrame=function(){return e.requestAnimationFrame||e.webkitRequestAnimationFrame||e.mozRequestAnimationFrame||e.oRequestAnimationFrame||e.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)}}(),n()}(window,document);
</script>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<script>
    function secondToDate(second) {
        if (!second) {
            return 0;
        }
        var time = new Array(0, 0, 0, 0, 0);
        if (second >= 365 * 24 * 3600) {
            time[0] = parseInt(second / (365 * 24 * 3600));
            second %= 365 * 24 * 3600;
        }
        if (second >= 24 * 3600) {
            time[1] = parseInt(second / (24 * 3600));
            second %= 24 * 3600;
        }
        if (second >= 3600) {
            time[2] = parseInt(second / 3600);
            second %= 3600;
        }
        if (second >= 60) {
            time[3] = parseInt(second / 60);
            second %= 60;
        }
        if (second > 0) {
            time[4] = second;
        }
        return time;
    }</script>
<script type="text/javascript" language="javascript">
    function setTime() {
        var create_time = Math.round(new Date(Date.UTC(2017, 08, 18, 11, 42, 23)).getTime() / 1000);
        var timestamp = Math.round((new Date().getTime() + 8 * 60 * 60 * 1000) / 1000);
        currentTime = secondToDate((timestamp - create_time));
        currentTimeHtml = 'Running：' + currentTime[0] + '年 ' + currentTime[1] + '天 '
                + currentTime[2] + '时 ' + currentTime[3] + '分 ' + currentTime[4]
                + '秒';
        document.getElementById("htmer_time").innerHTML = currentTimeHtml;
    }    setInterval(setTime, 1000);
</script>
<footer class="footer">
    <div class="top">
        

        <p>
          <span id="busuanzi_container_page_pv">
             [&nbsp;浏览量：&nbsp;<span id="busuanzi_value_page_pv"></span>&nbsp;]
          </span>
        </p>
    </div>
    <div class="bottom">
        <p>
        <span>BingZhenhuang &copy; 2017 - 2020</span>
            <span>
                
                Power by <a href="https://hhardyy.github.io/" target="_blank">zhen On August 8</a> 
            </span>
            <span id="htmer_time" "></span>
        </p>
    </div>
</footer>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://yoursite.com/2018/05/19/vue组件通信/&title=《vue组件通信》 — 小方块 - hhardyy.com&pic=http://yoursite.com/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://yoursite.com/2018/05/19/vue组件通信/&title=《vue组件通信》 — 小方块 - hhardyy.com&source=这里我没用脚手架，可以用html和js的思维了解，最重要的是这次的音乐是我最喜欢的Flower Dance
" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://yoursite.com/2018/05/19/vue组件通信/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《vue组件通信》 — 小方块 - hhardyy.com&url=http://yoursite.com/2018/05/19/vue组件通信/&via=http://yoursite.com" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://yoursite.com/2018/05/19/vue组件通信/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: true };


</script>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/main.min.js"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/search.min.js" async></script>








<script>
(function() {
    var OriginTitile = document.title, titleTime;
    document.addEventListener('visibilitychange', function() {
        if (document.hidden) {
            document.title = '(•‾̑⌣‾̑•)✧˖°回来看我';
            clearTimeout(titleTime);
        } else {
            document.title = '(゜-゜)つロ欢迎回来';
            titleTime = setTimeout(function() {
                document.title = OriginTitile;
            },2000);
        }
    });
})();
</script>



</body>
</html>
